import java.util.Arrays;
import java.util.HashSet;
import java.util.TreeSet;

public class 删除有序数组中的重复项 {

    public static void main(String[] args) {
        int[] nums = {0};
        System.out.println(removeDuplicates(nums));
        System.out.println(Arrays.toString(nums));
    }

    public static int removeDuplicates(int[] nums) {

        int i = 0;
        for (int j = 1; j < nums.length; j++) {
            if (nums[i] != nums[j]) {
                i++;
                nums[i] = nums[j];
            }
        }
        return i + 1;
    }
}
